package com.hrhx.springboot.web;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

import com.hrhx.springboot.bean.Greeting;
import com.hrhx.springboot.bean.HelloMessage;
/**
 * 
 * @author duhongming
 *
 */
@Controller
public class SocketController {
	
	@MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greeting(HelloMessage message) throws Exception {
		// simulated delay
		Thread.sleep(1000); 
        return new Greeting("Hello, " + message.getName() + "!");
    }
	
    @SendTo("/topic/line/data")
    public Object lineData(Object message) throws Exception {
		return message;
    }
    
    @SendTo("/topic/gauge/data")
    public Object gaugeData(Object message) throws Exception {
		return message;
    }

}
